<?php $this->renderPartial('/authItem/_buttons');?>
<?php $model = new AuthItemForm;?>
<?php $model->setAttributes(array(
    'name'=>$authItem->getName(),
    'type'=>$authItem->getType(),
    'description'=>$authItem->getDescription(),
));?>
<div class="createAuthItem">
	<h2>Update <?php echo $authItem->getTypeName();?></h2>
	<?php $this->renderPartial('_form', array('model'=>$model)); ?>
    <div class="form span-12 last">
        <table>
            <caption>Parents</caption>
            <?php foreach($parentAuthItems as $item):?>
            <tr>
                <td><?php echo $item->getUpdateNameLink();?></td>
                <td><?php echo $item->getTypeNameLink();?></td>
                <td><?php echo CHtml::link('delete', array('authItem/RemoveItemChild', 'itemName'=>$item->getName(), 'childItemName'=>$authItem->getName()));?></td>
            </tr>
            <?php endforeach;?>
        </table>
        <table>
            <caption>Children</caption>
            <?php foreach($childrenAuthItems as $item):?>
            <tr>
                <td><?php echo $item->getUpdateNameLink();?></td>
                <td><?php echo $item->getTypeNameLink();?></td>
                <td><?php echo CHtml::link('delete', array('authItem/RemoveItemChild', 'itemName'=>$authItem->getName(), 'childItemName'=>$item->getName()));?></td>
            </tr>
            <?php endforeach;?>
        </table>
        <?php if( ! empty($childrenAuthItemSelectOptions)):?>
        <div>
            <?php echo CHtml::beginForm(array('authItem/addChild', 'itemName'=>$authItem->getName()), 'post');?>
            <?php echo CHtml::dropDownList('childItemName', '', $childrenAuthItemSelectOptions);?>
            <input type="submit" value="Add" />
            <?php echo CHtml::endForm();?>
        </div>
        <?php endif;?>
    </div>
</div>